package com.bdqn.utils;

import com.bdqn.controller.BIllController;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author www
 * @Description: 拦截器
 * @date 2020-06-03 9:10
 */

public class SysInterceptor implements HandlerInterceptor {
    private Logger log= LogManager.getLogger(BIllController.class);
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
  log.info("进入拦截器");
        //判断当前用户是否登录
        Object attribute=request.getSession().getAttribute(Constants.USER_SESSION);
        if (attribute !=null){
            log.info("登录成功");
            return true;
        }
        return false;
    }
}
